package com.baoyi.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.baoyi.doamin.WorkItem;
import com.baoyi.landscape.BaoyiApplication;
import com.baoyi.service.WorkItemServiceImpl;
import com.baoyi.widget.ListLinearLayout;

public class Items extends BaseAdapter {

	private List<ListLinearLayout> items;
	private List<WorkItem> itemsss;

	public Items(Context context) {
		WorkItemServiceImpl workItemServiceImpl = new WorkItemServiceImpl();
		itemsss = workItemServiceImpl.listall();
		Log.d(BaoyiApplication.TAG, "获取作品");
		items = new ArrayList<ListLinearLayout>();
		if (null != itemsss) {
			for (WorkItem workItem : itemsss) {
				Log.d(BaoyiApplication.TAG, workItem.getLastcomments());
				items.add(new ListLinearLayout(context, workItem));
			}
		}

	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return items.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return itemsss.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		return items.get(position);
	}

}
